#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int MAXN = 1e5+10;

db f[MAXN][2],ans,p[MAXN],k;
int h[MAXN],cnt,n,root,fa[MAXN];
bool vis[MAXN];
struct edge{int v,nxt;}e[MAXN<<1];
void link(int x,int y){e[++cnt] = (edge){y,h[x]};h[x] = cnt;}

void fr(int x,int p){
	if(root) return;
	vis[x] = 1;fa[x] = p;
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v; if(y == p) continue;
		if(!vis[y]) fr(y,x);
		else {root = y;fa[y] = x;return;}
	}
}

void dfs(int x,int p){
	f[x][0] = 0; f[x][1] = ::p[x];
	for(int i = h[x];i;i = e[i].nxt){
		int y = e[i].v; if(y == p || y == root) continue;
		dfs(y,x); f[x][0] += max(f[y][0],f[y][1]); f[x][1] += f[y][0];
	}
}

int main (){
	n = in; for(int i = 1;i <= n;i++) p[i] = in;
	for(int i = 1;i <= n;i++){int x = in+1,y = in+1;link(x,y);link(y,x);} scanf("%lf",&k);
	fr(1,0); dfs(root,fa[root]); ans = max(ans,f[root][0]); root = fa[root];
	dfs(root,fa[root]); ans = max(ans,f[root][0]); printf("%.1lf",ans*k);
	return 0;
}

